require 'xm/platform'
group(:component) do
    jamm = XM::Platform.root.join("comps/cassandra/cassandra/lib/jamm-0.3.0.jar").to_s
    def before_start 
      canssandra_wd = File.expand_path("../cassandra_data/saved_caches",XM::Platform.root) 
      Dir.glob(File.join(canssandra_wd,"*")).each{|file| File.delete(file)} 
    end 
    java(:cassandra, "comps/cassandra/cassandra",
         :order => 75,
         :classpath => %W[conf lib/*.jar],
         :stdout=>"NUL",
         :java_options => %W{-ea -javaagent:#{jamm} -Xms#{cassandra_max} -Xmx#{cassandra_max} -XX:+HeapDumpOnOutOfMemoryError -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -XX:SurvivorRatio=8 -XX:MaxTenuringThreshold=1 -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -XX:+UseTLAB -XX:+PerfDisableSharedMem -XX:CMSWaitDuration=10000 -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintHeapAtGC -XX:+PrintTenuringDistribution -XX:+PrintGCApplicationStoppedTime -XX:+PrintPromotionFailure -Xloggc:./../logs/gc.log -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=5M -Dcom.sun.management.jmxremote.port=7199 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Dlogback.configurationFile=logback.xml -Dcassandra.logdir=./../logs -Dcassandra.storagedir=../../../../cassandra_data/storagedir -Dcassandra.hints_directory=../../../../cassandra_data/hints_directory -Dcassandra.commitlog.ignorereplayerrors=true -Dcassandra -Dcassandra-foreground=yes},
         :start => {:main => "org.apache.cassandra.service.CassandraDaemon"},
         :started => {:port => 9160,:max => 10.minutes},
         :mandatory => true,
         :stop => :kill)
end
